package com.py.korona.ui.activities.settings;

import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.py.korona.R;
import com.py.korona.db.UriBuilder;
import com.py.korona.db.model.CategoryEntity;
import com.py.korona.db.model.RoomEntity;

public class SettingsActivity extends FragmentActivity {
    TextView textViewStatus;
    Button   buttonGenerateRecords;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings_detail_container);
        textViewStatus = (TextView) this.findViewById(R.id.textViewSettingsStatus);
        buttonGenerateRecords = (Button) this.findViewById(R.id.buttonGenerateDBRecords);
        buttonGenerateRecords.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ContentValues contentValues = new ContentValues();
                for (int i = 1001; i < 1100; i++) {
                    contentValues.put("text", String.format("room_%d", i));
                    Uri contentUri = UriBuilder.objectListUri(RoomEntity.uriAuthority(), RoomEntity.uriBasePath());
                    getContentResolver().insert(contentUri, contentValues);
                    textViewStatus.setText(String.format("Status: room[%d]", i));
                }
                for (int i = 1001; i < 1100; i++) {
                    contentValues.put("text", String.format("category_%d", i));
                    Uri contentUri = UriBuilder.objectListUri(CategoryEntity.uriAuthority(), CategoryEntity.uriBasePath());
                    getContentResolver().insert(contentUri, contentValues);
                    textViewStatus.setText(String.format("Status: category[%d]", i));
                }
            }
        });
    }
}
